#include <iostream>
#include <math.h>
using namespace std; 

int main(){
	float w,x,y,z;
	float h,p,b;
	// 计算sin(pitch)
	float sp = -2.0f * (y*z + w*x);
	// 检查万向锁，允许一定误差
	if(fabs(sp) > 0.9999f){
		// 向正上或正下看
		p = 1.570796f * sp;
		// 计算heading,bank置零
		h = atan2(-x*z - w*y, 0.5f - y*y - z*z);
		b = 0.0f;
	}else{
		// 计算角度
		p = asin(sp);
		h = atan2(x*z - w*y, 0.5f - x*x - y*y);
		b = atan2(x*z - w*z, 0.5f - x*x - z*z);
	}
	return 1;
}